import type { Posts } from "./post";

export interface createTags {
  name: string;
}

export interface TagsShow extends createTags {
  id: number;
}

export interface Tags extends createTags {
  id: number;
  name: string;
  post?: Posts[];
  createTime: Date;
  uploadTime: Date;
}

export const create = ({ name }: createTags) => {
  //开始请求
  return useServerRequest<Tags>("/tags", {
    method: "POST",
    body: {
      name,
    },
  });
};

export const findAll = () => {
  return useServerRequest<TagsShow[]>("/tags", {
    method: "GET",
  });
};

export const getRelation = () => {
  return useServerRequest<{ id: number; name: string; value: number }[]>(
    "/tags/getRelation",
    {
      method: "GET",
    }
  );
};
